package com.xsky.logic;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class RecordWriter 
{
	private static RecordWriter recordWriter;
	private RecordWriter()
	{
		
	}
	public static RecordWriter getInstance()
	{
		if(recordWriter==null)
		{
			recordWriter = new RecordWriter();
		}
		return recordWriter;
	}
	public void writeFile(File file, String info)
	{
		if(!file.exists())
		{
			try
			{
				file.createNewFile();
			} catch (IOException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		FileWriter fw =null;
		BufferedWriter bw  = null;
		try
		{
			fw = new FileWriter(file,true);
			bw = new BufferedWriter(fw);
			bw.write(info);
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			try {
				bw.flush();
				bw.close();
				fw.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
